﻿@inherits Project.Engine.Control.BasePageRazor
@{
    ViewBag.Title = "Sự Kiện";
    Layout = "~/Views/Home/_Master.cshtml";
    Project.Module.View.ChiTietSuKienView eventView = this.Model.DocumentObject as Project.Module.View.ChiTietSuKienView;
}
<div id="noidung">
    <h1>Chi tiết sự kiện</h1>
    @if(eventView != null && eventView.detailEvent != null) {
        <div><img src="@eventView.detailEvent.ImagePath"/></div>
        <div class="noidung"><h1>@eventView.detailEvent.title</h1><p>@eventView.detailEvent.Description</p></div>
        <div class="binhluan">
            <h1>Bình luận</h1>
            <form method="post">
            <textarea class="message" id="comment"></textarea>
            </form>
            <div class="nut">
                <input type="submit" value="Gửi" id="btnSend" />
                <input type="submit" value="Xóa hết" id="btnCancel" />
            </div>
            @if (eventView.comment != null && eventView.comment.ToList().Count > 0) { 
            <h3>Các lời bình (@eventView.comment.ToList().Count bình luận)</h3>
            <div>
                @foreach (var item in eventView.comment) { 
                <div class="bl">
                    <p><em>@item.CreatedBy:</em></p>
                    <p>@item.Content</p>
                </div> 
                }
            </div>
            }
        </div>     
    }
</div>
<!--end #noidung-->

<script type="text/javascript">
    $('#btnSend').click(function () {
        var link = '/su-kien/binh-luan';
        var comment = document.getElementById('comment').value;
        var url = window.location.href;

        if (comment.length == 0) {
            alert("Bạn chưa nhập bình luận");
            return false;
        }

        $.post(link, { 'comment': comment, 'url': url }, function (data) {
            if (data.result == 0) {
                window.location.reload();
            }
        });

        document.getElementById('comment').value = '';
        // return
        return false;
    });

    $('#btnCancel').click(function () {
        document.getElementById('comment').value = '';
        // return
        return false;
    });
</script>
